A typical computer system has several processes that perform functions on one or more resources. A process is a series of actions, changes, or procedures that bring about a result. A process may be an instance of an application in execution or a thread in execution. The resource that the process uses may be a file, a socket, a database, or virtually any other object. The process may try to modify the resource in some manner or simply read from the resource.
As a mechanism to provide greater throughput in execution, processes are often executed concurrently. Thus, during execution of one process, another process may also execute. While concurrent execution provides better throughput, concurrent execution may also have an effect on the reliability of the resources. For example, two processes may try to access the same resource at the same time. Reliability of the resource is ensured when more than one process can access the same resources seamlessly without any loss of data, corruption of data, non-availability of product feature, or without suffering performance degradation.
One programming language used in designing the applications of the processes is JAVA™ developed by Sun Microsystems™, Inc. (located in Santa Clara, Calif.). JAVA™ is a cross-platform object oriented programming language. In order to support the variety of platforms (i.e. Operating Systems), such as Solaris™, Microsoft® Windows, Unix®, Linux®, and MacOS® by Apple® Computer, Inc. (located in Cupertino, Calif.) and ensure JAVA™ applications are portable, JAVA™ programs are compiled into JAVA™ byte code by the JAVA™ Compiler and executed by the JAVA™ Virtual Machine. Once the JAVA™ Virtual Machine has been implemented for a particular computer running a particular platform, JAVA™ bytecode may be executed on the particular computer. The JAVA™ Virtual Machine acts as a container for the JAVA™ application. Accordingly, a single instance of the JAVA™ Virtual Machine may run one or more applications and/or one or more instances of the same application. Further, one or more instances of the JAVA™ Virtual Machine may be executed on the same computer. Regardless of the number of JAVA™ instances of one or more applications, for each instance of the JAVA™ Virtual Machine executing on the computer, the operating system recognizes only one application running on the computer.
Thus, if two or more applications are operating on the same JAVA™ Virtual Machine and requesting the same resource, the Operating System recognizes the requests as coming from the same application. Accordingly, the operating system is unable to ensure reliability of a resource shared by the multiple instances running on the same JAVA™ Virtual Machine.
One method for ensuring reliability is to use a separate application of a locking server. In this method, the only route to the resource is through the locking server. Specifically, each process must register with the locking server an identification of the resource the process is interested in accessing. If a process is trying to access the same resource that is already registered with the locking server by another process, then the process is refused access to the resource.
Another mechanism for reliability in resource sharing is for the process to check for a file associated with the resource before accessing the resource. If the file exists, then another process is accessing the resource and the first process must wait. Once a process has completed accessing the resource, then the process deletes the file associated with the resource.